package org.reliablesource.jdt.model;

import org.reliablesource.model.core.IReliableElement;
import org.reliablesource.model.core.ReliableNode;

/**
 * 
 * Contributor.java<br>
 * Copyright (c) 2007, Reliable Source, Inc. All Rights Reserved<br>
 * <br>
 * 
 * Created on: May 10, 2007 <br>
 * <br>
 * 
 * @author Dennis Park <a
 *         href="mailto:dennis.park@gmail.com">dennis.park@gmail.com</a>
 * 
 * @since 1.0.0
 */
public class Contributor extends ReliableNode implements IContributor {

	private static final long serialVersionUID = 7124710211635666247L;
	protected int loc;
	protected int nFiles;

	public Contributor() {
		super();
	}

	public Contributor(String _name) {
		this();
		setName(_name);
		setId(_name);
	}

	public int getLOC() {
		IReliableElement[] _elts = getChildren();
		int _nLines = 0;
		for (int i = 0; i < _elts.length; i++)
			_nLines += ((JavaElementAdapter) _elts[i]).getNumLines();
		return _nLines;
	}

	public ISourceElementInfo getChild(String _byName) {
		for (int i = 0; i < children.size(); i++)
			if (children.get(i).getName().equals(_byName))
				return (ISourceElementInfo) children.get(i);
		return null;
	}

	public int getNumFiles() {
		IReliableElement[] _elts = getChildren();
		int _nFiles = 0;
		for (int i = 0; i < _elts.length; i++)
			_nFiles += ((JavaElementAdapter) _elts[i]).getNumFiles();
		return _nFiles;
	}
}
